//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for LexRuntimeService
public struct LexRuntimeServiceErrorType: AWSErrorType {
    enum Code: String {
        case badGatewayException = "BadGatewayException"
        case badRequestException = "BadRequestException"
        case conflictException = "ConflictException"
        case dependencyFailedException = "DependencyFailedException"
        case internalFailureException = "InternalFailureException"
        case limitExceededException = "LimitExceededException"
        case loopDetectedException = "LoopDetectedException"
        case notAcceptableException = "NotAcceptableException"
        case notFoundException = "NotFoundException"
        case requestTimeoutException = "RequestTimeoutException"
        case unsupportedMediaTypeException = "UnsupportedMediaTypeException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize LexRuntimeService
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.
    public static var badGatewayException: Self { .init(.badGatewayException) }
    ///  Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes.
    public static var badRequestException: Self { .init(.badRequestException) }
    ///  Two clients are using the same AWS account, Amazon Lex bot, and user ID.
    public static var conflictException: Self { .init(.conflictException) }
    ///  One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example,    If Amazon Lex does not have sufficient permissions to call a Lambda function.   If a Lambda function takes longer than 30 seconds to execute.   If a fulfillment Lambda function returns a Delegate dialog action without removing any slot values.
    public static var dependencyFailedException: Self { .init(.dependencyFailedException) }
    /// Internal service error. Retry the call.
    public static var internalFailureException: Self { .init(.internalFailureException) }
    /// Exceeded a limit.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// This exception is not used.
    public static var loopDetectedException: Self { .init(.loopDetectedException) }
    /// The accept header in the request does not have a valid value.
    public static var notAcceptableException: Self { .init(.notAcceptableException) }
    /// The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.
    public static var notFoundException: Self { .init(.notFoundException) }
    /// The input speech is too long.
    public static var requestTimeoutException: Self { .init(.requestTimeoutException) }
    /// The Content-Type header (PostContent API) has an invalid value.
    public static var unsupportedMediaTypeException: Self { .init(.unsupportedMediaTypeException) }
}

extension LexRuntimeServiceErrorType: Equatable {
    public static func == (lhs: LexRuntimeServiceErrorType, rhs: LexRuntimeServiceErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension LexRuntimeServiceErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
